package layeredneuralnetwork;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class BackpropagationThread extends Thread {
	public LayeredNeuralNetwork nn;
	public double eta;
	public double dMicron;
	public double[] desiredValues;
	public boolean completed = false;
	private List<HashMap<Weight,RefDouble>> weightsToAdjust;
	
	public BackpropagationThread(LayeredNeuralNetwork nn, double eta, double dMicron, double[] desiredValues)
	{
		this.nn = nn;
		this.eta = eta;
		this.dMicron = dMicron;
		this.desiredValues = desiredValues;
		this.completed = false;
	}
	
	public BackpropagationThread(LayeredNeuralNetwork nn)
	{
		this.nn = nn;
	}
	
	public void LoadParams(double eta, double dMicron, double[] desiredValues)
	{
		this.eta = eta;
		this.dMicron = dMicron;
		this.desiredValues = desiredValues;
		this.completed = false;
	}
	
	public void run()
	{
		weightsToAdjust = nn.BackPropagate(eta, dMicron, desiredValues, false);
		completed = true;
	}
	
	public void adjustWeights()
	{
		nn.BackPropagateAdjustWeights(eta, weightsToAdjust);
	}

}
